<template>
  <a-modal
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-descriptions :title="formInfo.title">
      <a-descriptions-item label="创建日期">{{ formInfo.createTime }}</a-descriptions-item>
      <a-descriptions-item label="业务流水号">{{ formInfo.busNo }}</a-descriptions-item>
      <a-descriptions-item label="业务标识">{{ formInfo.busType }}</a-descriptions-item>
      <a-descriptions-item label="患者姓名">{{ formInfo.payer }}</a-descriptions-item>
      <a-descriptions-item label="业务时间">{{ formInfo.busDateTime }}</a-descriptions-item>
      <a-descriptions-item label="开票状态">{{ formInfo.fpFlag==0?'未开票':'已开票' }}</a-descriptions-item>

      <a-descriptions-item label="开票点编码">{{ formInfo.placeCode }}</a-descriptions-item>
      <a-descriptions-item label="发票状态">{{ formInfo.result=='S0000'?'成功':'失败' }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.result!='S0000'" label="开票信息">{{ formInfo.message }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.result=='S0000'" label="电子票据代码">{{ formInfo.billBatchCode }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.result=='S0000'" label="电子票据号码">{{ formInfo.billNo }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.result=='S0000'" label="电子校验码">{{ formInfo.random }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.result=='S0000'" label="电子票据生成时间">{{ formInfo.createTimep }}</a-descriptions-item>
      <a-descriptions-item label="是否红冲">{{formInfo.billFlag==0?'否':'是' }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.billFlag!=0" label="红冲原因">{{ formInfo.reason }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.billFlag!=0" label="红冲经办人">{{ formInfo.operator }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.billFlag!=0" label="红冲状态">{{ formInfo.billResult=='S0000'?'成功':'失败' }}</a-descriptions-item>
      <a-descriptions-item v-if="formInfo.billFlag!=0&&formInfo.billResult!='S0000'" label="红冲信息">{{ formInfo.billMessage }}</a-descriptions-item>
    </a-descriptions>
  </a-modal>
</template>

<script>
  import pick from 'lodash.pick'
  import { getAction } from '@/api/manage'

  export default {
    name: 'UserWaterInvoiceView',
    components: {},
    data () {
      return {
        visible: false,
        confirmLoading: false,
        formInfo: {},
        url: {
          saveInfo: '/system/userWaterInvoice/save',
          getInfo: '/system/userWaterInvoice/info'
        }
      }
    },
    created () {
    },
    methods: {
      show (record) {
        this.formInfo = Object.assign({}, record)
        if (this.formInfo.id) {
          getAction(this.url.getInfo, { 'id': record.id }).then(res => {
            this.$nextTick(() => {
              this.formInfo = (pick(res.result.data
        , 'id'
        , 'createTime'
        , 'busNo'
        , 'busType'
        , 'payer'
        , 'busDateTime'
        , 'invoicetext'
        , 'fpFlag'
        , 'recordid'
        , 'placeCode'
        , 'result'
        , 'message'
        , 'billBatchCode'
        , 'billNo'
        , 'random'
        , 'createTimep'
        , 'billFlag'
        , 'reason'
        , 'operator'
                  ,'billResult'
                  ,'billMessage'
              ))
            })
          })
        }
        this.visible = true
      },
                                                                                                                                                                              // 确定
      handleSubmit () {
        this.visible = false
      },
      // 关闭
      handleCancel () {
        this.close()
      },
      close () {
        this.visible = false
      }
    }
  }
</script>
